
// // pages/commit_record/index.js
import API from "../../api/index";
Component({

  /**
   * 组件的初始数据
   */
  data: {
    type:['待处理','已处理','抄送我的' ],
        tabIndex:0,
        total: 15,
        list: [],
        start:0,
        count:6,
        showmore:false
      },
  /**
   * 组件的方法列表
   */
  methods: {
    toggle(e){
        this.setData({tabIndex:e.currentTarget.dataset.index})
        if(this.data.tabIndex==0||this.data.tabIndex==1){
            this.setData({list:[],total:0,start:0})
            this._getExamineList()
        }else{
            this._getCarbonCopy()
        }
     },
     _getCarbonCopy(){
        if(this.data.list.length<this.data.total || (this.data.list.length<=this.data.total&&this.data.start==0)){
            // is_deal:false-待处理，true-已处理
            API.getCarbonCopy({start:this.data.start,count:this.data.count,is_deal:this.data.tabIndex==0?false:true}).then(res=>{
              this.setData({
                list:[...(this.data.start == 0 ? [] : this.data.list),...res.data.items],
                total:res.data.total
              })
              this.setData({showmore:this.data.list.length<this.data.total?false:true})
            })
          }
     },
    _getExamineList(){
      if(this.data.list.length<this.data.total || (this.data.list.length<=this.data.total&&this.data.start==0)){
        // is_deal:false-待处理，true-已处理
        API.getExamineList({start:this.data.start,count:this.data.count,is_deal:this.data.tabIndex==0?false:true}).then(res=>{
          this.setData({
            list:[...(this.data.start == 0 ? [] : this.data.list),...res.data.items],
            total:res.data.total
          })
          this.setData({showmore:this.data.list.length<this.data.total?false:true})
        })
      }
    },
    skip(e){
        wx.navigateTo({
            url: "/pages/approve_detail/index?id="+e.currentTarget.dataset.id,
        })
     }
  },
  ready(){
    this._getExamineList()
  },
})